package cn.oa.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import cn.oa.dao.SystemRoleMapper;
import cn.oa.pojo.SystemRole;

@Controller
public class RoleController {

	@Resource(name = "systemRoleMapper")
	SystemRoleMapper srm;

	@RequestMapping("/rolelist")
	public String rolelist(HttpServletRequest request,
			@RequestParam(name = "currentPage", required = false, defaultValue = "1") int currentPage,
			@RequestParam(name = "pageSize", required = false, defaultValue = "2") int pageSize) {

		int start = (currentPage - 1) * pageSize;
		List<SystemRole> list = srm.selectAll(start, pageSize);

		int count = srm.count();

		request.setAttribute("count", count);
		request.setAttribute("currentPage", currentPage);
		request.setAttribute("pageSize", pageSize);
		request.setAttribute("list", list);
		return "role/rolelist";
	}

}
